<{include file="tpl/filter.tpl"}>

<style>
	.contain{
		margin-top: 10px;
		padding-left: 10px;
		font-size:13px;
		margin-right: 10px;
		font-family: 微软雅黑, "Source Sans Pro", sans-serif;
		width: 100%;
		background-color: #FFFFFF;
		padding-bottom:30px;
		padding-top: 10px;
	}
	
    
a.ncap-btn-big { text-decoration: none;font: bold 14px/20px "microsoft yahei", arial; color: #FFFFFF; background-color: #5cb85c; text-align: center; vertical-align: middle; display: inline-block;  padding: 7px 19px; border: solid 1px #5cb85c; border-radius: 3px; cursor: pointer; }
a:hover.ncap-btn-big { text-decoration: none; color: #FFFFFF; background-color: #5cb85c; box-shadow: 0 0 0 2px rgba(82, 168, 236, 0.15); }

	
.ncap-account-container { display: block; min-height: 20px; padding: 0px 10px 10px 40px; margin-right: 16px;margin-left: 6px; }
.ncap-account-container:nth-child(even) { background: #FFFFFF; }
.ncap-account-container:hover { background: #F4FCFA; }
.ncap-account-container h4 { font-size: 13px; font-weight: normal; color: #666; text-align: right; vertical-align: top; display: inline-block; *display: inline/*IE7*/;
 margin-right: 1%; *zoom: 1;margin-left: 5px;
}
.ncap-account-container-list { font-size: 0; *word-spacing:-1px/*IE6銆�7*/;
vertical-align: top; display: inline-block; *display: inline/*IE7*/;
width: 100%; padding-left: 1%; *zoom: 1;margin-left:20px;
}
.ncap-account-container-list li { font-size: 13px; line-height: 20px; color: #999; vertical-align: top; letter-spacing: normal; word-spacing: normal; display: inline-block; *display: inline/*IE7*/;
padding-right: 30px; height: 25px; margin-bottom: 5px; *zoom: 1;
}
.bot{margin-left: 530px; margin-top: 30px;}


.alert-warning {
    color: red;
    padding: 20px 0px 20px 20px;
}
</style>

<div class="contain">
	    <{if count($data) == 0}>
	    	<div class="alert-warning">无该状态的专服</div>
	    <{else}>	
	    <div class="ncap-form-default">
			
			<dl class="row">
				
				<dd style="margin-left:0px;">
					<div class="ncap-account-container" style="height: 30px;margin-left: -10px;">
						<h4>
							<input id="cls_full" type="checkbox">
							<label>全选</label>
						</h4>
					</div>
					<{foreach from=$data item=item key=key}>
						<div class="ncap-account-container" style="">
							<h4>
								<input value="" cka="mod-<{$key}>" type="checkbox">
								<label><{$key}></label>
							</h4>
							<ul class="ncap-account-container-list">
								<{foreach from=$item item=val key=k}>
									<li>
										<label><input class="checkbox" name="server_id[]" value="<{$val.develop_id}>" ck="mod-<{$key}>" type="checkbox">&nbsp;&nbsp;<{$val.server_name}></label>
									</li>
								<{/foreach}>								
							</ul>
						</div>
					<{/foreach}>	
				</dd>
			</dl>
			<div class="bot"><a href="JavaScript:void(0);"  class="ncap-btn-big" id="submitBtn" data-url="<{$url}>">确认提交</a></div>
		</div>
		<{/if}>
</div>


<script>
   $('#cls_full').on('ifChecked', function(event){
   	   $('input').iCheck('check');
   });
   
   $('#cls_full').on('ifUnchecked', function(event){
   	   $('input').iCheck('uncheck');
   });
   
   $(':checkbox[cka]').on('ifChecked', function(event){
   	   var cks = $(":checkbox[ck='"+$(this).attr("cka")+"']");
   	   cks.each(function(){
   	   	  $(this).iCheck('check');
   	   });
   });
   
   $(':checkbox[cka]').on('ifUnchecked', function(event){
   	   var cks = $(":checkbox[ck='"+$(this).attr("cka")+"']");
   	   cks.each(function(){
   	   	  $(this).iCheck('uncheck');
   	   });
   });
   
   var flag = true;
    $("#submitBtn").click(function(){
    	
    	var arr = new Array();
        $("input[name='server_id[]']:checkbox[checked]").each(function(i){
            arr[i] = $(this).val();
        });
        var server = arr.join(",");
        if(server == ''){
        	layer.msg('请选择服务器', {icon: 2,time: 2000});
        	return false;
        }
            
        if(!flag){
    		return false;
    	}
    	flag = false;
    	$("#submitBtn").text('提交中...');
    	var index = layer.load(0, {shade: false});
        var url = $(this).attr('data-url');
        console.log(url);
    	$.ajax({
    		type : 'POST',
    		url : url,
			data : {'server_id':server},
			dataType :'JSON',
			success : function(res){
				flag = true;
				if(res.status == 1){
					layer.close(index);
					$("#submitBtn").text('确认提交');
					layer.msg('操作成功', {icon: 1,time: 2000});
				}else{
					layer.msg('操作失败', {icon: 2,time: 2000});
				}
			}
		});
    });
   

</script>